<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\Users;

/**
 * Description of Register
 *
 * @author hasee
 */
class Register extends Controller{
    //put your code here
    public function register(){
        return view("/register/register");
    }
    public function add(Request $request){
        //第一步：接受前端传递的参数
        $param=$request->param();
        var_dump($param);
        echo '<br>';
        $data['uname']=$param['user'];
        $data['upwd']= sha1($param['pwd']);
        $data['uemail']=$param['email'];
        echo '<br>';
        //第二步：操作数据表并返回结果
        $result=Users::create($data);
        //第三步：处理结果
        if($result){
            $this->success("注册成功","index/login/login");
        } else {
            $this->error("注册失败，继续努力","index/register/register");
        }
    }
}
